package org.btik.light.meta;

import java.util.Map;
import java.util.Objects;

public abstract class DevMo implements LightDevAttrConstant {
    /**
     * 设备序列号
     * serialNumber
     */
    protected String sn;


    /**
     * 连接状态
     * serialNumber
     */
    protected DevState devState;

    /**
     * 设备类型
     */
    protected String devType;

    /**
     * 设备版本
     */
    protected String version;

    /**
     * 显示版本，格式不受制约，不用于比较大小
     */
    protected String displayVersion;

    protected Map<String, String> extendedAttributes;


    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    public DevState getDevState() {
        return devState;
    }

    public void setDevState(DevState devState) {
        this.devState = devState;
    }

    public String getDevType() {
        if (Objects.isNull(devType)) {
            devType = extendedAttributes.get(DEV_TYPE);
        }
        return devType;
    }

    public void setDevType(String devType) {
        this.devType = devType;
    }

    public String getVersion() {
        if (Objects.isNull(version)) {
            version = extendedAttributes.get(DEV_VERSION);
        }
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public Map<String, String> getExtendedAttributes() {
        return extendedAttributes;
    }

    public void setExtendedAttributes(Map<String, String> extendedAttributes) {
        this.extendedAttributes = extendedAttributes;
    }

    public void setExtendedAttribute(String key, Object value) {
        if (this.extendedAttributes == null) {
            return;
        }
        extendedAttributes.put(key,String.valueOf(value));
    }

    public DevMo(String sn, DevState devState) {
        this.sn = sn;
        this.devState = devState;
    }

    public DevMo() {
    }
}
